<?php
function echoPositionRow($position, $i) {
    echo getEchoTR($i, "center");
    echo<<<EOQ
      <td>$position->qty</td>
      <td>$position->position</td>
      <td>$position->cost</td>
      <td>$position->ma</td>
      <td>$position->st</td>
      <td>$position->ag</td>
      <td>$position->av</td>
      <td align="left">
EOQ;
    if (strlen($position->skillsStr) > 40) {
        echo "<font size=\"-1\">" . $position->skillsStr . "</font>";
    } else {
        echo $position->skillsStr;
    }
    echo<<< EOQ
</td>
      <td>$position->skillGroupsStr</td>
    </tr>
EOQ;
}
/* Start of page */
include ("includes/init.php");

$noSeasonChange = true;
$showRaceLinks = true;
$race_id = $_GET["race_id"];
$race = $races[$race_id];
$raceText = $race->getRaceDisplay();
$title = $raceText . " details";
include ("includes/header.php");
echo<<< EOQ
<caption><h1>$raceText</h1></caption>
<tr>
  <th>Max<br />Qty</th>
  <th>Position</th>
  <th>Cost</th>
  <th>MA</th>
  <th>ST</th>
  <th>AG</th>
  <th>Av</th>
  <th>Skills</th>
  <th>Normal-Double</th>
</tr>
EOQ;
$i = 0;
foreach ($race->positions as $position) {
    if ($position->isJourneyman()) {
        continue;
    }
    echoPositionRow($position, ++ $i);
}
echo getEchoTR(++ $i) . "<td colspan=\"9\" align=\"right\">&nbsp;</td></tr>\n" . getEchoTR($i);
echo<<< EOQ
  <th colspan="2" align="center">Reroll Cost</th>
  <td colspan="7" align="left">$race->rerollCost k</td>
</tr>

EOQ;
echo getEchoTR(++ $i);
echo<<< EOQ
  <td colspan="9" align="left"><a href="team_creator.php?race_id=$race->id">Create $raceText Team</a></td>
</tr>
EOQ;
echo getEchoTR(++ $i);
$ruleLong = $ruleSets[$race->getRuleId()]->getLongName();
echo<<< EOQ
  <td colspan="9" align="left"><br />Rules: $ruleLong<br />$race->comments</td>
</tr>
EOQ;
if (count($race->similar) > 0) {
		echo<<< EOQ
	        <td colspan="9">Change to alternative rule set: 
EOQ;
	foreach($race->similar as $otherId) {
		$other = getRace($otherId);
		if ($other) {
			$popup = $other->getRaceDisplay();
			$text = $other->getShortRuleSetName();
		echo<<< EOQ
	        <a href="race_viewer.php?race_id=$other->id" title="$popup">$text</a>
EOQ;
		}
	}
		echo<<< EOQ
	        </td></tr> 
EOQ;
	
}
include ("includes/footer.php");
?>
